package pl.smath.expression.model.presentation;

import pl.smath.expression.model.NumberTerm;
import pl.smath.expression.model.Term;
import pl.smath.expression.model.VariableTerm;

public class FunctionMappingTerm extends PresentationTerm {

	private Term function;
	private Term from;
	private Term to;
	
	public FunctionMappingTerm(Term function, Term from, Term to) {
		super("");
		this.function = function;
		this.from = from;
		this.to = to;
	}

	/**
	 * @return the function
	 */
	public Term getFunctionTerm() {
		return function;
	}

	/**
	 * @param function the function to set
	 */
	public void setFunctionTerm(Term function) {
		this.function = function;
	}

	/**
	 * @return the from
	 */
	public Term getFromTerm() {
		return from;
	}

	/**
	 * @param from the from to set
	 */
	public void setFromTerm(Term from) {
		this.from = from;
	}


	/**
	 * @return the to
	 */
	public Term getToTerm() {
		return to;
	}

	/**
	 * @param to the to to set
	 */
	public void setToTerm(Term to) {
		this.to = to;
	}



	/**
	 * Sprawdzenie czy 2 wartości bezwgledne wyrazenia sa sobie równowazne.
	 */
	public boolean isAbsTheSame(Term term){
		if (!(term instanceof FunctionMappingTerm))
			return false;
		
		return (function.isAbsTheSame(((FunctionMappingTerm)term).getFunctionTerm())  &&  
				from.isAbsTheSame(((FunctionMappingTerm)term).getFromTerm())  &&
				to.isAbsTheSame(((FunctionMappingTerm)term).getToTerm()));
	}
	
	public String toString(){

		String output = "";
		
		if(isNegative())
			output = "-";
		
		output += function.toString() + ":" + from.toString() + "-" + to.toString();
		
		return output;
	}

}
